Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outline compiler #6114

Merged
merged 20 commits into from May 20, 2024
Merged

Outline compiler #6114

merged 20 commits into from May 20, 2024

Conversation

kasiaMarek
Copy link
Contributor

@kasiaMarek kasiaMarek commented Feb 13, 2024

connected to: #917

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

Let's also add a user setting to enable the new logic.

val richCompilationCache: TrieMap[String, RichCompilationUnit] =
TrieMap.empty[String, RichCompilationUnit]

// for those paths units were
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a bit more to the comment here


def successfulCompilation(): Unit = {
wasSuccessfullyCompiled.set(true)
changedDocuments.clear()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: that this doesn't account for possible changes before compilation end is reported, it may not 100% reflect the state of files that was during compilation.

.asJava
Some(
OutlineFiles(
allFiles,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to cap the number of files for initial compilation, so it won't take too long.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do a high number like 300 or something

@kasiaMarek kasiaMarek force-pushed the outline-compiler branch 2 times, most recently from 6675382 to d1060a8 Compare March 20, 2024 08:03
@kasiaMarek
Copy link
Contributor Author

Failing Scala3 NIGHTLY test is a test-only problem, so it shouldn't block this PR.

@kasiaMarek kasiaMarek requested a review from tgodzik March 26, 2024 16:15
else false
}

// TODO the same in autoimports TEST
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we check auto imports? Is the TODO still relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added tests, this seems to be already handled

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments, but I also tested it on Metals codebase this workflow seems to break:

  1. Add non compiling method to the MD5 object in mtagsShared
  2. Change the name of MD5 to MD55
  3. Try to auto import MD55 in another package.
  4. We get completions for MD5 aside from MD55 and something like MD55.<local>

Could you take a look if you can reproduce it?

@@ -101,6 +104,10 @@ class Compilers(

import compilerConfiguration._

val plugins = new CompilerPlugins()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val plugins = new CompilerPlugins()

I don't think it's used here now.

s"no build target found for $path. Using presentation compiler with project's scala-library version: ${scalaVersion}"
)
Some(fallbackCompiler)
case None => Some(fallbackCompiler)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

} provider.didChange(path)
}

def getOutlineFiles(id: String): Optional[JOutlineFiles] =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this id? Should we use BuildTargetIdentifier here? Or at least add an alias.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is BuildTargetIdentifier, I'm constructing it here.

  def getOutlineFiles(id: String): Optional[JOutlineFiles] =
    getOutlineFiles(buildTargetId(id))

  def getOutlineFiles(
      buildTargetId: Option[BuildTargetIdentifier]
  )

It's just that it comes as a string from pc (can't be BuildTargetIdentifier, because pc interface doesn't depend on bsp4j) and it's less boilerplate to map it here instead of each place in Compilers.

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's wait for the next release and merge it right after.

Great work!

@kasiaMarek kasiaMarek force-pushed the outline-compiler branch 2 times, most recently from 1f7ab2f to a15c8af Compare May 20, 2024 09:42
@kasiaMarek kasiaMarek merged commit 76a9a65 into scalameta:main May 20, 2024
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants